Skip to content

feat(core): add sharedSignal for cross-tab state sync#4

Merged
wrxck merged 2 commits intomainfrom
feat/shared-signal
Feb 11, 2026
Merged

feat(core): add sharedSignal for cross-tab state sync#4
wrxck merged 2 commits intomainfrom
feat/shared-signal

Conversation

@wrxck
Copy link
Owner

@wrxck wrxck commented Feb 11, 2026

Summary

  • Adds sharedSignal(key, initial) — a signal that syncs across browser tabs via BroadcastChannel
  • Intercepts .set()/.update() to broadcast changes, with echo-loop prevention
  • Falls back to a plain signal when BroadcastChannel is unavailable (SSR)
  • Supports custom serialize/deserialize and close() for cleanup
  • 10 tests with MockBroadcastChannel simulating multi-tab messaging

Test plan

  • All 478 tests pass (existing + 10 new)
  • Build succeeds cleanly

Matt Hesketh added 2 commits February 11, 2026 17:12
Add sharedSignal(key, initialValue) — a reactive signal that
automatically syncs its value across browser tabs via BroadcastChannel.

- Broadcasts local .set()/.update() calls to other tabs
- Receives remote updates and applies them reactively
- Prevents echo loops (remote updates don't re-broadcast)
- Supports custom serialize/deserialize for non-JSON types
- Falls back to a plain signal when BroadcastChannel is unavailable
- close() tears down the channel
- 10 new tests including multi-tab, bidirectional, and SSR fallback
@wrxck wrxck merged commit 4503b8e into main Feb 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant